<template>
  <view class="comp-b">
    <view class="comp-title">子组件B</view>
    <view class="comp-content">
      <text>CompA组件传进来的值：</text>
      <text class="value-text">{{ fromCompA }}</text>
    </view>
    <view class="back-group">
      <text class="label">回传值：</text>
      <input v-model="backInput" class="back-input" placeholder="输入回传值" />
      <button class="back-btn" @click="backToMain">回传</button>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    fromCompA: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      backInput: "1001-278684"
    };
  },
  methods: {
    backToMain() {
      this.$emit("back-to-main", this.backInput);
    }
  }
};
</script>

<style scoped>
.comp-b {
  background-color: #90be6d;
  border-radius: 10rpx;
  padding: 20rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.comp-title {
  font-size: 30rpx;
  font-weight: bold;
  margin-bottom: 15rpx;
  color: #333;
}

.comp-content {
  font-size: 28rpx;
  margin-bottom: 20rpx;
  color: #333;
}

.value-text {
  color: #004aad;
  font-weight: 500;
}

.back-group {
  display: flex;
  align-items: center;
  font-size: 28rpx;
}

.label {
  margin-right: 10rpx;
  color: #333;
}

.back-input {
  flex: 1;
  padding: 12rpx 15rpx;
  border: 1px solid #ddd;
  border-radius: 6rpx;
  margin-right: 10rpx;
  font-size: 28rpx;
}

.back-btn {
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  padding: 12rpx 20rpx;
  border-radius: 6rpx;
  font-size: 28rpx;
}
</style>